{% extends "templates/panoptic_base.html" %}

{% block meta_block %}
{% include "templates/includes/meta_block.html" %}
{% endblock %}

{% block content %}
<section class="container border-b border-r border-l flex">
	<article class="text-white border-r w-full md:w-2/3">
		<div class="p-5 md:p-8 lg:p-12">
			<div class="prose prose-md">
				<h1>{{ title }}</h1>
				{{ frappe.utils.md_to_html(application_body) }}
			</div>
		</div>
		<div class="flex flex-wrap border-t p-5 md:p-8 lg:p-12">
			<div class="w-full md:w-1/2">
				<div class="md:hidden">
					<div class="mt-2 text-teal-blue-300">
						Filed to: <b>{{ authority }}</b>
					</div>
					<div class="mt-2 text-teal-blue-300">
						Status: <b>{{ status }}</b>
					</div>
				</div>
				<div class="text-teal-blue-300 mt-2 md:mt-0">Published By</div>
				{% set member_doc = frappe.get_doc("Team Member", rti_filed_by) %}
				{{ web_block(
					"Avatar",
					values={
						"member": member_doc,
						"mt": 4
					},
					add_container=0,
					add_top_padding=0,
					add_bottom_padding=0,
				) }}
			</div>
			<div class="w-full md:w-1/2 md:text-right mt-6 md:mt-0">
				<span class="text-teal-blue-300">Share this RTI</span>
				<div class="mt-2 md:mt-4">
					<a href="https://twitter.com/intent/tweet?text=RTI%20filed%20to%20{{ authority }}%20by%20%23ProjectPanoptic&url={{ site_url }}/{{ route }}"
					class="text-teal-blue-200 fa fa-twitter" target="_blank"></a>

					<a href="https://www.facebook.com/sharer.php?u={{ site_url }}/{{ route }}"
						class="text-teal-blue-200 ml-2 fa fa-facebook" target="_blank"></a>

					<a href="https://www.linkedin.com/sharing/share-offsite/?url={{ site_url }}/{{ route }}"
						class="text-teal-blue-200 ml-2 fa fa-linkedin" target="_blank"></a>

					<a href="mailto:?subject=Panoptic {{ category }}: {{ title }}&body={{ site_url }}/{{ route }}"
						class="text-teal-blue-200 ml-2 fa fa-envelope" target="_blank"></a>
				</div>
			</div>
		</div>
	</article>
	<div class="p-12 hidden md:block w-full md:w-1/3 text-teal-blue-300">
		<div class="mb-12">
			<h3>Details</h3>
			<div class="mt-4">
				<div class="mt-2">
					RTI Filed to: <b>{{ authority }}</b>
				</div>
				<div class="mt-2">
					RTI Status: <b>{{ status }}</b>
				</div>
				{% if rti_number %}
				<div class="mt-2">
					RTI Number: <b>{{ rti_number }}</b>
				</div>
				{% endif %}
				<div class="mt-2">
					RTI Filed on: <b>{{ frappe.format_date(filed_on) }}</b>
				</div>
				{% if application_attachment %}
				<div class="mt-4">
					<a class="text-orange-500 hover:underline" href="{{ application_attachment }}">Download Application
						Copy</a>
				</div>
				{% endif %}
			</div>
		</div>

		{% if status == "Response Received" and response_attachment %}
		<div class="mb-12">
			<h3>Response</h3>
			<div class="mt-4">
				<div class="mt-2">
					Received On: <b>{{ frappe.format_date(response_received_on) }}</b>
				</div>
				<div class="mt-2">
					<a class="text-orange-500 hover:underline" href="{{ response_attachment }}">Download Response</a>
				</div>
			</div>
		</div>
		{% endif %}

		<div class="mb-12">
			<h3>RTI Filed By</h3>
			{{ web_block(
				"Avatar",
				values={
					"member": member_doc,
					"mt": 4
				},
				add_container=0,
				add_top_padding=0,
				add_bottom_padding=0,
			) }}
		</div>

		{%- if frts|length -%}
		<div class="mb-12">
			<h3>Linked FRTs</h3>
			<ul class="mt-3">
				{% for link_frt in frts %}
				<li class="mb-1">
					<a class="hover:underline text-orange-500" href="/{{ link_frt.route }}">
						{{ link_frt.authority }}</a>
				</li>
				{% endfor %}
			</ul>
		</div>
		{%- endif -%}

		<div class="mb-12">
			<span class="text-teal-blue-300">Share this RTI</span>
			<div class="mt-4">
				<a href="https://twitter.com/intent/tweet?text=RTI%20filed%20to%20{{ authority }}%20by%20%23ProjectPanoptic&url={{ site_url }}/{{ route }}"
					class="text-teal-blue-200 fa fa-twitter" target="_blank"></a>

				<a href="https://www.facebook.com/sharer.php?u={{ site_url }}/{{ route }}"
					class="text-teal-blue-200 ml-2 fa fa-facebook" target="_blank"></a>

				<a href="https://www.linkedin.com/sharing/share-offsite/?url={{ site_url }}/{{ route }}"
					class="text-teal-blue-200 ml-2 fa fa-linkedin" target="_blank"></a>

				<a href="mailto:?subject=Panoptic {{ category }}: {{ title }}&body={{ site_url }}/{{ route }}"
					class="text-teal-blue-200 ml-2 fa fa-envelope" target="_blank"></a>
			</div>
		</div>

		<div class="">
			<a href="https://rti.gov.in/" target="_blank" rel="noopener noreferrer" class="hover:underline">Learn more
				about RTI</a>
		</div>
	</div>
</section>
{% endblock %}
